<?php


namespace app\admin\controller;

use think\Controller;
use think\Db;

class Art extends Base
{

    public function index()
    {

        if (request()->isAjax()) {
            $page = input('page') ? input('page') : 1;
            $limit = input('limit') ? input('limit') : 10;
            $gd = Db::name('goods');

            $res = $gd->page($page, $limit)->select();
            foreach ($res as $index => $re) {
                $res[$index]['create_time'] = date('Y-m-d H:i:s', $re['create_time']);
            }
            $this->success('ok', '', $res);

        } else {
            $count = Db::name('goods')->count();
            $this->assign('count', $count);
            return $this->fetch();
        }

        // for ($i=0;$i<7;$i++){
        //     foreach ($res as $index => $re) {
        //         $data=$re;
        //         unset($data['id']);
        //         // var_dump($data);
        //         $gd->insertGetId($data);
        //     }
        // }

    }

}
